package la.bbs558.aop.valid;


import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

/**
 * @author KLJ
 */
@Target({ElementType.FIELD, ElementType.PARAMETER})
@Retention(RetentionPolicy.RUNTIME)
public @interface Valid {

    String DEFAULT_MSG = "参数异常！";

    ValidEnum value() default ValidEnum.IS_VALID;

    boolean enableCondition() default false;

    ValidEnum condition() default ValidEnum.IS_VALID;

    String msg() default DEFAULT_MSG;

    String[] group() default {};

    String[] parentsGroup() default {};

    boolean internal() default true;

    boolean isArray() default false;

    boolean isJsonString() default false;

    Class<?> jsonToClass() default Object.class;

    @Target({ElementType.FIELD, ElementType.PARAMETER})
    @Retention(RetentionPolicy.RUNTIME)
    @interface batch {

        Valid[] value() default {};

    }

    @Target({ElementType.FIELD, ElementType.PARAMETER})
    @Retention(RetentionPolicy.RUNTIME)
    @interface filter {

        Class<? extends ValidFilter>[] value() default {};

    }

    @Target({ElementType.FIELD, ElementType.PARAMETER})
    @Retention(RetentionPolicy.RUNTIME)
    @interface regex {

        String value() default "";

        String msg() default DEFAULT_MSG;

        @Target({ElementType.FIELD, ElementType.PARAMETER})
        @Retention(RetentionPolicy.RUNTIME)
        @interface batch {

            Valid.regex[] value() default {};

        }

    }


}
